package com.codingfly.config;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class GlobalConfig {

    public static final Cache<String, Integer> tokenStorage = CacheBuilder.newBuilder()
            .initialCapacity(500)
            .concurrencyLevel(2) // 设置并发数为5，即同一时间最多只能有5个线程往cache执行写入操作
            .expireAfterWrite(30, TimeUnit.MINUTES) // 过期时间为半小时
            .build();

    public static final Cache<String, String> sessionVerifyCode = CacheBuilder.newBuilder()
            .initialCapacity(500)
            .concurrencyLevel(2) // 设置并发数为5，即同一时间最多只能有5个线程往cache执行写入操作
            .expireAfterWrite(2, TimeUnit.MINUTES) // 过期时间为2分钟
            .build();

    public static final ThreadPoolExecutor threadPool = new ThreadPoolExecutor(2, 10, 60L, TimeUnit.SECONDS, new LinkedBlockingQueue());

}
